<table id="auth_model_datagrid" ></table>
<script type="text/javascript">
$(function(){

	$('#auth_model_datagrid').datagrid({
		iconCls:'icon-save',
		width:'auto',
		height:'auto',
		nowrap: false,
		fit:true,
		singleSelect:true,
		fitColumns:true,
		striped: true,
		url:'${request.contextPath}${namespace?default('')}/mp/auth/model-datagrid.json',
		sortName: 'id',
		sortOrder: 'desc',
		remoteSort: true,
		idField:'id',
		onBeforeLoad:function(){$('#auth_model_datagrid').datagrid('unselectAll');},
		columns:[[
					//{field:'ck',checkbox:true},
					{field:'id',title:'${action.getDatagridTitle('id')}',width:40,align:'center',sortable:true},
					{field:'title',title:'${action.getDatagridTitle('title')}',width:80,align:'center',sortable:true},
					{field:'caozuo',title:'${action.getProperty('net.esj.background.message','bg.datagrid.action')}',width:20,align:'center',sortable:false,formatter:function(val, rec){
						return '<a href="javascript:;;" onclick="auth_model_edit(\''+rec.id+'\')" >${action.getProperty('net.esj.background.message','bg.datagrid.modify')}</a>';
					}}
				]],
		pagination:true,
		rownumbers:true,
		toolbar:[{
			id:'btnadd',
			text:'${action.getProperty('net.esj.background.message','bg.datagrid.add')}',
			iconCls:'icon-add',
			handler:function(){
				$('<div/>').dialog({
					href:'${request.contextPath}${namespace?default('')}/mp/auth/model-form.htm',
					width:500,   
					height:400,   
					title: '${action.getText('form.add.title')}',
					modal:true,
					maximizable:false,
					collapsible:false,
					minimizable:false,
					resizable:false,
					buttons:[{iconCls : 'icon-ok',
								text:'${action.getProperty('net.esj.background.message','bg.datagrid.save')}',
								handler:function(){
									var d = $(this).closest('.window-body');
									$('#auth_model_form').form('submit', {
										url : '${request.contextPath}${namespace?default('')}/mp/auth/model-add.json',
										onSubmit: function(){
											return $(this).form('validate');
				        				},
										success : function(json) {
											eval("json="+json);
											$.messager.alert(json.title,json.msg,json.level);
											d.dialog('destroy');
											$("#auth_model_datagrid").datagrid('reload');
										}
									});
								}}],
					onClose : function() {
						$(this).dialog('destroy');
					}
				});
			}
		}]
	});

	$('#group_addForm').form({
		onLoadSuccess:function(){
			alert();
		}
	})
});

function auth_model_edit(id) {
	$('<div>').dialog({
		href : '${request.contextPath}${namespace?default('')}/mp/auth/model-edit.htm',
		width:500,   
		height:400,   
		modal : true,
		title : '${action.getText('form.edit.title')}',
		buttons : [ {
			text : '${action.getProperty('net.esj.background.message','bg.datagrid.edit')}',
			iconCls : 'icon-edit',
			handler : function() {
				var d = $(this).closest('.window-body');
				$('#auth_model_form').form('submit', {
					url : '${request.contextPath}${namespace?default('')}/mp/auth/model-update.json',
					onSubmit: function(){
						return $(this).form('validate');
    				},
					success : function(json) {
						eval("json="+json);
						$.messager.alert(json.title,json.msg,json.level);
						d.dialog('destroy');
						$("#auth_model_datagrid").datagrid('reload');
					}
				});
			}
		} ],
		onClose : function() {
			$(this).dialog('destroy');
		},
		onLoad : function() {
			$.get('${request.contextPath}${namespace?default('')}/mp/auth/model-load.json?id='+id+'&n='+Math.random(),{},function(data){
				eval("data="+data);
				$('#auth_model_form').form('load',data);
			});
		}
	});
}

</script>	